home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / ulog / RCS / Ulog_RecordLogout.c,v < prev    next >
Encoding:
Text File  |  1989-01-02  |  4.3 KB  |  207 lines

  1. head     1.5;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.5
  10. date     89.01.02.13.54.25;  author douglis;  state Exp;
  11. branches ;
  12. next     1.4;
  13.  
  14. 1.4
  15. date     88.09.22.22.14.59;  author douglis;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     88.09.15.10.17.33;  author douglis;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.09.13.16.44.48;  author douglis;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.08.14.15.12.23;  author douglis;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @ecord information that someone has logged out, removing them from the
  37. list of people logged into the current machine.
  38. @
  39.  
  40.  
  41. 1.5
  42. log
  43. @added call to Host_End.
  44. @
  45. text
  46. @/* 
  47.  * ULog_RecordLogout.c --
  48.  *
  49.  *    Source code for the ULog_RecordLogout procedure.
  50.  *
  51.  * Copyright 1988 Regents of the University of California
  52.  * Permission to use, copy, modify, and distribute this
  53.  * software and its documentation for any purpose and without
  54.  * fee is hereby granted, provided that the above copyright
  55.  * notice appear in all copies.  The University of California
  56.  * makes no representations about the suitability of this
  57.  * software for any purpose.  It is provided "as is" without
  58.  * express or implied warranty.
  59.  */
  60.  
  61. #ifndef lint
  62. static char rcsid[] = "$Header: Ulog_RecordLogout.c,v 1.4 88/09/22 22:14:59 douglis Exp $ SPRITE (Berkeley)";
  63. #endif not lint
  64.  
  65.  
  66. #include <ulog.h>
  67. #include "ulogInt.h"
  68.  
  69.  
  70. /*
  71.  *----------------------------------------------------------------------
  72.  *
  73.  * Ulog_RecordLogout --
  74.  *
  75.  *    Remove information for a user from the database after the user
  76.  *     logs out.
  77.  *
  78.  *    Note: for now, this just nulls out the "user log" entry showing
  79.  *    who's logged in on a particular host/port combination.  It
  80.  *    can later be modified to update a "last" like database showing time
  81.  *    logged out as well as time logged in.
  82.  *
  83.  * Results:
  84.  *    -1 indicates an error, in which case errno indicates more details.
  85.  *    0 indicates success.
  86.  *
  87.  * Side effects:
  88.  *    The database file is updated.
  89.  *
  90.  *----------------------------------------------------------------------
  91.  */
  92.  
  93. /* ARGSUSED */
  94. int
  95. Ulog_RecordLogout(uid, portID)
  96.     int uid;        /* user identifier */
  97.     int portID;        /* index into host's area in userLog */
  98. {
  99.     int status;
  100.     char myHostName[ULOG_LOC_LENGTH];
  101.     char buffer[ULOG_RECORD_LENGTH];
  102.     Host_Entry *hostPtr;
  103.  
  104.     if (portID >= ULOG_MAX_PORTS || portID < 0) {
  105. #ifdef DEBUG
  106.     syslog(LOG_ERR, "recording logout: invalid port: %d\n", portID);
  107. #endif
  108.     errno = EINVAL;
  109.     return(-1);
  110.     }
  111.  
  112.     if (gethostname(myHostName, ULOG_LOC_LENGTH) < 0) {
  113.     syslog(LOG_ERR, "Ulog_RecordLogout: error in gethostname.\n");
  114.     return(-1);
  115.     }
  116.     hostPtr = Host_ByName(myHostName);
  117.     Host_End();
  118.     if (hostPtr == (Host_Entry *) NULL) {
  119.     syslog(LOG_ERR,
  120.            "Ulog_RecordLogout: error in Host_ByName for current host.\n");
  121.     return(-1);
  122.     }
  123.  
  124.     bzero(buffer, ULOG_RECORD_LENGTH);
  125.     (void) sprintf(buffer, ULOG_FORMAT_STRING, -1, hostPtr->id, portID,
  126.              0, "(none)");
  127.  
  128.     status = Db_WriteEntry(ULOG_FILE_NAME, buffer,
  129.                hostPtr->id * ULOG_MAX_PORTS + portID,
  130.                ULOG_RECORD_LENGTH, DB_LOCK_BREAK);
  131.     return(status);
  132. }
  133. @
  134.  
  135.  
  136. 1.4
  137. log
  138. @changed order of args to DB_*Entry routines.
  139. @
  140. text
  141. @d17 1
  142. a17 1
  143. static char rcsid[] = "$Header: Ulog_RecordLogout.c,v 1.3 88/09/15 10:17:33 douglis Exp $ SPRITE (Berkeley)";
  144. d72 1
  145. @
  146.  
  147.  
  148. 1.3
  149. log
  150. @fixed bug using uninitialized structure for hostID instead of taking
  151. it from hostPtr.
  152. @
  153. text
  154. @d17 1
  155. a17 1
  156. static char rcsid[] = "$Header: Ulog_RecordLogout.c,v 1.2 88/09/13 16:44:48 douglis Exp $ SPRITE (Berkeley)";
  157. d75 1
  158. d82 1
  159. a82 1
  160.     status = Db_WriteEntry(ULOG_FILE_NAME,
  161. d84 1
  162. a84 1
  163.                ULOG_RECORD_LENGTH, buffer, DB_LOCK_BREAK);
  164. @
  165.  
  166.  
  167. 1.2
  168. log
  169. @changed to use ascii representation in database file.
  170. @
  171. text
  172. @d17 1
  173. a17 1
  174. static char rcsid[] = "$Header: Ulog_RecordLogout.c,v 1.1 88/08/14 15:12:23 douglis Exp $ SPRITE (Berkeley)";
  175. a53 1
  176.     Ulog_Data data;
  177. d82 1
  178. a82 1
  179.                data.hostID * ULOG_MAX_PORTS + portID,
  180. @
  181.  
  182.  
  183. 1.1
  184. log
  185. @Initial revision
  186. @
  187. text
  188. @d17 1
  189. a17 1
  190. static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
  191. d57 1
  192. a58 1
  193.     int hostID;
  194. a67 5
  195.     data.uid = -1;
  196.     data.portID = portID;
  197.     data.updated = 0;
  198.     data.location[0] = '\0'; 
  199.  
  200. a76 1
  201.     hostID = hostPtr->id;
  202. d78 7
  203. a84 2
  204.     status = Db_WriteEntry(ULOG_FILE_NAME, hostID * ULOG_MAX_PORTS + portID,
  205.                sizeof(data), (char *) &data, DB_LOCK_BREAK);
  206. @
  207.